package cn.zte.com.train.hiber8train;

import java.util.EnumSet;

import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;
/**
 * 
 * @author XiaoMotian
 * 根据hbm配置文件生成数据库
 */
public class ExportDB {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//默认读取hibernate.cfg.xml文件  
		ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
		MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ).buildMetadata();
		SchemaExport schemaExport = new SchemaExport();
		schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata);
	}

}
